package com.laiyima.zhongjiang.linghuilv.demo.util;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;


public class FixedEditText extends  androidx.appcompat.widget.AppCompatEditText {
    private String leadText = null;
    public FixedEditText(Context context) {
        super(context);
    }

    public FixedEditText(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public FixedEditText(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }
    @Override
    protected void onDraw(Canvas canvas) {
        Paint paint = new Paint();
        paint.setTextSize(50);//自定义字大小
        paint.setColor(Color.BLACK);//自定义字颜色
        canvas.drawText(getLeadText(),10,getHeight()/2+20,paint);
        int paddingLeft = (int) paint.measureText(getLeadText())+30;
        //设置距离光标距离左侧的距离
        setPadding(paddingLeft, getPaddingTop(), getPaddingRight(), getPaddingBottom());
        super.onDraw(canvas);
    }
    public void setLeadText(String s){
        leadText = s;
    }

    public String getLeadText(){
        return leadText;
    }


}